<?php
$usernameexist=$_GET[usernameexist];
$emailexist=$_GET[emailexist];

if ($usernameexist and $usernameexist!=''){
	echo '<script language="javascript">alert("The username: '.$usernameexist.' exists already. If you are sure you don\'t have an account with Horizon Academy, please modify the username (s) and try again.")</script>;';	
}
if ($emailexist and $emailexist!=''){
	echo '<script language="javascript">alert("The email address: '.$emailexist.' exists already. If you are sure you don\'t have an account with Horizon Academy, please set unique email address and try again.")</script>;';	
}
?>

<html>
<head>
<title>Horizon Academy Registration</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="keywords here">
<meta name="description" content="description here">
<meta name="author" content="Mohammed Belyamani">
<meta name="publisher" content="interspire.com">
<meta name="robots" content="index, follow"> <!-- (robot commands: all, none, index, no index, follow, no follow) -->
<meta name="revisit-after" content="30 days">
<meta name="distribution" content="global"> 
<meta name="rating" content="general">
<meta name="content-language" content="english">
<script type="text/javascript">
function to_home()
{
    window.location.href='default.php';
}
function to_activities()
{
    window.location.href='activities.html';
}
function to_organisation()
{
    window.location.href='organisation.html';
}
function to_link()
{
    window.location.href='link.html';
}
function to_contactus()
{
    window.location.href='contactus.html';
}
function add_sibling()
{
        document.write('<input type="text" />');
}

function addElement() {
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  alert('myDiv element: '+numi +', the value :'+ num);
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>';
  ni.appendChild(newdiv);
}


function addElementTable() {
  var buttonRemove = document.getElementById('RemoveSibling');
  buttonRemove.disabled=false;
  
  var ni = document.getElementById('tableForm');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value);
  numi.value = parseInt(num)+1;
  document.getElementById('countfixing').value = 0;
  
  var student_n = parseInt(num) + 1;
  
  var newtrkid = document.createElement('tr');
  newtrkid.id = 'divkid'+student_n;
  var newtdkid = document.createElement('td');
  newtdkid.innerHTML = '<br /><b>Child '+student_n+' information</b>: '; 
  newtrkid.appendChild(newtdkid);
  var newtdkidtxt = document.createElement('td');
  newtdkidtxt.innerHTML = ''; 
  newtrkid.appendChild(newtdkidtxt);
  ni.appendChild(newtrkid);
  
  var newtrun = document.createElement('tr');
  newtrun.id = 'divun'+student_n;
  var newtdun = document.createElement('td');
  newtdun.innerHTML = 'Username:'; 
  newtrun.appendChild(newtdun);
  var newtduntxt = document.createElement('td');
  newtduntxt.innerHTML = '<input class=\'editfield\' type=\'text\' id=\'username'+num+'\'  name=\'username'+num+'\' />'; 
  newtrun.appendChild(newtduntxt);  
  ni.appendChild(newtrun);
    
  var newtrpwd = document.createElement('tr');
  newtrpwd.id = 'divpwd'+student_n;
  var newtdpwd = document.createElement('td');
  newtdpwd.innerHTML = 'Password:'; 
  newtrpwd.appendChild(newtdpwd);
  var newtdpwdtxt = document.createElement('td');
  newtdpwdtxt.innerHTML = '<input class=\'editfield\' type=\'password\' id=\'password'+num+'\'  name=\'password'+num+'\' />'; 
  newtrpwd.appendChild(newtdpwdtxt);
  ni.appendChild(newtrpwd);
  
  var newtrfn = document.createElement('tr');
  newtrfn.id = 'divfn'+student_n;
  var newtdfn = document.createElement('td');
  newtdfn.innerHTML = 'First name:'; 
  newtrfn.appendChild(newtdfn);
  var newtdfntxt = document.createElement('td');
  newtdfntxt.innerHTML = '<input class=\'editfield\' type=\'text\' id=\'firstname'+num+'\' name=\'firstname'+num+'\' />'; 
  newtrfn.appendChild(newtdfntxt);
  ni.appendChild(newtrfn);
  
  var newtrln = document.createElement('tr');
  newtrln.id = 'divln'+student_n;
  var newtdln = document.createElement('td');
  newtdln.innerHTML = 'Last name:'; 
  newtrln.appendChild(newtdln);
  var newtdlntxt = document.createElement('td');
  newtdlntxt.innerHTML = '<input class=\'editfield\' type=\'text\' id=\'lastname'+num+'\' name=\'lastname'+num+'\' />';
  newtrln.appendChild(newtdlntxt);
  ni.appendChild(newtrln);
  
  var newtremail = document.createElement('tr');
  newtremail.id = 'divemail'+student_n;
  var newtdemail = document.createElement('td');
  newtdemail.innerHTML = 'Email:'; 
  newtremail.appendChild(newtdemail);
  var newtdemailtxt = document.createElement('td');
  newtdemailtxt.innerHTML = '<input class=\'editfield\' type=\'text\' id=\'email'+num+'\' name=\'email'+num+'\' />';
  newtremail.appendChild(newtdemailtxt);
  ni.appendChild(newtremail);
  
  var newtrdob = document.createElement('tr');
  newtrdob.id = 'divdob'+student_n;
  var newtddob = document.createElement('td');
  newtddob.innerHTML = 'Birth date:'; 
  newtrdob.appendChild(newtddob);
  var newtddobselect = document.createElement('td');
  newtddobselect.innerHTML = '<select id=\'month'+num+'\'  name=\'month'+num+'\'><option> - Month - </option><option value=\'01\' >January</option>'+
								'<option value=\'02\'  >Febuary</option><option value=\'03\'  >March</option>'+
								'<option value=\'04\'  >April</option><option value=\'05\'  >May</option>' +
								'<option value=\'06\'  >June</option><option value=\'07\'  >July</option>' +
								'<option value=\'08\'  >August</option><option value=\'09\'  >September</option>' +
								'<option value=\'10\'  >October</option><option value=\'11\'  >November</option>' +
								'<option value=\'12\'  >December</option></select>'+
							'<select id=\'day'+num+'\'  name=\'day'+num+'\'><option> - Day - </option>'+
								'<option value=\'01\'  >1</option><option value=\'02\'  >2</option>'+
								'<option value=\'03\'  >3</option><option value=\'04\'  >4</option>'+
								'<option value=\'05\'  >5</option><option value=\'06\'  >6</option>'+
								'<option value=\'07\'  >7</option><option value=\'08\'  >8</option>'+
								'<option value=\'09\'  >9</option><option value=\'10\'  >10</option>'+
								'<option value=\'11\'  >11</option><option value=\'12\'  >12</option>'+
								'<option value=\'13\'  >13</option><option value=\'14\'  >14</option>'+
								'<option value=\'15\'  >15</option><option value=\'16\'  >16</option>'+
								'<option value=\'17\'  >17</option><option value=\'18\'  >18</option>'+
								'<option value=\'19\'  >19</option><option value=\'20\'  >20</option>'+
								'<option value=\'21\'  >21</option><option value=\'22\'  >22</option>'+
								'<option value=\'23\'  >23</option><option value=\'24\'  >24</option>'+
								'<option value=\'25\'  >25</option><option value=\'26\'  >26</option>'+
								'<option value=\'27\'  >27</option><option value=\'28\'  >28</option>'+
								'<option value=\'29\'  >29</option><option value=\'30\'  >30</option>'+
								'<option value=\'31\'  >31</option></select>' +
							'<select id=\'year'+num+'\' name=\'year'+num+'\'><option> - Year - </option>'+
								'<option value=\'2007\'  >2007</option>'+
								'<option value=\'2006\'  >2006</option><option value=\'2005\'  >2005</option>'+
								'<option value=\'2004\'  >2004</option><option value=\'2003\'  >2003</option>'+
								'<option value=\'2002\'  >2002</option><option value=\'2001\'  >2001</option>'+
								'<option value=\'2000\'  >2000</option><option value=\'1999\'  >1999</option>'+
								'<option value=\'1998\'  >1998</option><option value=\'1997\'  >1997</option>'+
								'<option value=\'1996\'  >1996</option></select>';
  newtrdob.appendChild(newtddobselect);
  ni.appendChild(newtrdob);
 
  var newtrgender = document.createElement('tr');
  newtrgender.id = 'divgender'+student_n;
  var newtdgender = document.createElement('td');
  newtdgender.innerHTML = 'Gender:'; 
  newtrgender.appendChild(newtdgender);
  var newtdgendertxt = document.createElement('td');
  newtdgendertxt.innerHTML = '<select id=\'gender'+num+'\' name=\'gender'+num+'\'><option value=\'male\'>Male</option>'+
							 '<option value=\'female\'>Female</option></select>';
  newtrgender.appendChild(newtdgendertxt);
  ni.appendChild(newtrgender);
  
}

function removeSibling() {
	var numi = document.getElementById('theValue');
	var num = (document.getElementById('theValue').value);
	var origKidNumber = (document.getElementById('theOriginalValue').value);
	
	if (origKidNumber < numi.value ){
		removeElement('divkid'+num);
		removeElement('divun'+num);
		removeElement('divpwd'+num);
		removeElement('divfn'+num);
		removeElement('divln'+num);
		removeElement('divemail'+num);
		removeElement('divdob'+num);
		removeElement('divgender'+num);
		numi.value = parseInt(num) - 1;
		
		if ( origKidNumber == numi.value){
			var buttonRemove = document.getElementById('RemoveSibling');
			buttonRemove.disabled = true;
		}
	}
}

function removeElement(divNum) {
  var d = document.getElementById('tableForm');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}

function validateForm(){
	var pusername = document.getElementById('username');
	if (pusername==null || pusername.value==null || pusername.value=='')
	  {
	  alert("Parent username must be filled out");
	  return false;
	  }
	var password =  document.getElementById('password');
	if (password!=null)
	{
		if (password.value==null || password.value=='')
		{
			alert("Parent password must be filled out");
			return false;
		}
		var re = /^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W]).*$/;
		var validPassword = re.test(password.value);
		if (!validPassword)
		{
			alert("The password must have 8 charachters; at least one number, one lowercase, one uppercase lettert, and one special character");
			return false;
		}
	}
	  
	var pfirstname = document.getElementById('firstname');
	if (pfirstname==null || pfirstname.value==null || pfirstname.value=='')
	  {
	  alert("Parent first name must be filled out");
	  return false;
	  }
	var plastname = document.getElementById('lastname');
	if (plastname==null || plastname.value==null || plastname.value=='')
	  {
	  alert("Parent last name must be filled out");
	  return false;
	  }
	var pemail = document.getElementById('email');
	if (pemail==null || pemail.value==null || pemail.value=='')
	  {
	  alert("Parent email must be filled out");
	  return false;
	  }
	var phone1 = document.getElementById('phone1');
	if (phone1==null || phone1.value==null || phone1.value=='')
	  {
	  alert("Parent phone1 must be filled out");
	  return false;
	  }
	var address = document.getElementById('address');
	if (address==null || address.value==null || address.value=='')
	  {
	  alert("Parent address must be filled out");
	  return false;
	  }
	var city = document.getElementById('city');
	if (city==null || city.value==null || city.value=='')
	  {
	  alert("Parent city must be filled out");
	  return false;
	  }
}
//-->
</script>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body style="margin:0;">
<table width="747" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="images/spacer.gif" width=747 height=11 alt=""></td>
  </tr>
  
  <tr>
    <td><img src="images/spacer.gif" width=747 height=11 alt=""></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top" background="images/pixi_lightgrey.gif"><table border=0 cellpadding=0 cellspacing=0 bgcolor="#ffffff">
          <tr bgcolor="#ffffff">
            <td colspan=3><!-- #BeginEditable "mainpic" --><img src="images/logotip.jpg" width=250 height=125 alt=""><!-- #EndEditable --></td>
          </tr>
          <tr> </tr>
          
        </table></td>
        <td valign="top" background="images/pixi_lightgrey.gif"><table width="516" border=0 cellpadding=0 cellspacing=0>
          <tr>
            <td rowspan=2><img src="images/spacer.gif" width=0 height=250 alt=""></td>
            <td height="30" background="images/pixi_headergrey.gif" align="center"> <h1><img src="images/spacer.gif" width=450 height=10 alt=""><br />
<br />Horizon Academy 2011-2012</h1><br /></td>
          </tr>
          <tr>
            <td height="216" valign="top"><img src="images/spacer.gif" width=450 height=20 alt=""><br>



			
			
<form method="post" action="saveparent.php"  onsubmit="return validateForm()" > 
 
 <input type="hidden" name="evaluation" value="Horizon Academy registration 2010-2011"/>
 
<table> 
 
<tr> 
  <td style="padding-bottom: 10px;" colspan="2"><h4>Pre-registration 2011-2012</h4>
  <p>This form is designed for parent to create a single parent account before pre-registering any student(s).</p>
  </td> 
</tr> 
<tr> 
  <td colspan="2"><p>All the fields are required except "Phone2" field.<br />
  *: The password must have 8 charachters; at least one number, one lowercase, one uppercase lettert, and one special character.
  </p></td> 
</tr>
 
<tr>
        <td colspan="2">
                <table  id="tableForm">
						<tr> 
                          <td><br /><b>Parent Information:</b></td> 
                          <td></td> 
                        </tr>
						
						<tr> 
                          <td><b>Username:</b></td> 
                          <td><input class="editfield" type="text" id="username" name="username"/>						  
						  </td> 
                        </tr> 
						
						<tr> 
                          <td><b>Password*:</b></td> 
                          <td><input class="editfield" type="password" id="password" name="password"/>
						  </td> 
                        </tr>
						
						<tr> 
                          <td><b>First name:</b></td> 
                          <td><input class="editfield" type="text" id="firstname" name="firstname"/></td> 
                        </tr> 
                        <tr> 
                          <td><b>Last name:</b></td> 
                          <td><input class="editfield" type="text" id="lastname" name="lastname"/></td> 
                        </tr> 
                        <tr> 
                          <td><b>E-mail:</b></td> 
                          <td><input class="editfield" type="text" id="email" name="email"/></td> 
                        </tr>
						<tr> 
                          <td><b>Phone1:</b></td> 
                          <td><input class="editfield" type="text" id="phone1" name="phone1"/></td> 
                        </tr>
						<tr> 
                          <td>Phone2:</td> 
                          <td><input class="editfield" type="text" id="phone2" name="phone2"/></td> 
                        </tr>
						<tr> 
                          <td><b>Address:</b></td> 
                          <td><input class="editfield" type="text" id="address" name="address"/></td> 
                        </tr>
						<tr> 
                          <td><b>City:</b></td> 
                          <td><input class="editfield" type="text" id="city" name="city"/></td> 
                        </tr>
						
                </table>
        </td> 
</tr>
<tr> 
  <td colspan="2"><p></p></td> 
</tr> 
<tr> 
  <td colspan="2"><input type="submit" value="Save" /></td> 
</tr>

</table> 
</form>  

 
            </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="747" border=0 cellpadding=0 cellspacing=0>
  <tr>
    <td width="15" align="left" valign="top" background="images/pixi_grey.gif"> <img src="images/basecurve_left.jpg" width=15 height=38 alt=""></td>
    <td background="images/pixi_grey.gif"> <img src="images/spacer.gif" width=218 height=1 alt=""></td>
    <td width="522" valign="top" background="images/pixi_grey.gif"><img src="images/spacer.gif" alt="" width=522 height=13 hspace="0" vspace="0"><br>
        <span class="baseline">Copyright 2011 Horizon Academy Institute</span></td>
    <td width="14" align="right" valign="top" background="images/pixi_grey.gif"><img src="images/basecurve_right.jpg" width=11 height=38 alt=""></td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td><img src="images/spacer.gif" width=747 height=11 alt=""></td>

  </tr>
</table>


<script src="form-validation.js"></script> 

</body>

</html>
